﻿using Wolfpack.Core.Interfaces;
using Wolfpack.Core.Interfaces.Entities;
using Wolfpack.Core.Interfaces.Magnum;
using Wolfpack.Core.Publishers;

namespace Wolfpack.Contrib.Publishers.MongoDb
{
    public class MongoDbPublisher : PublisherBase, INotificationEventPublisher
    {
        private readonly INotificationRepository _repository;

        public MongoDbPublisher(MongoDbConfiguration config)
        {
            _repository = new MongoDbRepository(config);

            Enabled = config.Enabled;
            FriendlyId = config.FriendlyId;
        }

        public override void Initialise()
        {
            _repository.Initialise();
        }

        public void Consume(NotificationEvent notification)
        {
            _repository.Add(notification);
        }
    }
}